<?php

//$ptn = sprintf("|user\(%s\) in action.*?next action time:.*?$|sm", $email);
//echo "processing $log_file <br />";

$log = file_get_contents($log_file);
$offset = 0;
$begin_ptn = "user($email) in action";
$end_ptn = "profiled:";

$count = substr_count($log, $begin_ptn);
if ($count > 0) {
  echo  $count . " actions <br />";
}
while (True) {
  $pos = strpos($log, $begin_ptn, $offset);
  if ($pos === False) {
    break;
  }
  $end_pos = strpos($log, $end_ptn, $pos);

  if ($end_pos === False) {
    echo "failed to find matching 'next action time'...<br />";
    continue;
  } else {
    $end_pos = strpos($log, "\n", $end_pos);
  }
  $cur = substr($log, $pos, $end_pos - $pos);
  echo "<pre>$cur</pre>";
  echo "<br /><hr /><br />"; 
  $offset = $pos + 1;
}

/* $match_count = preg_match_all($ptn, $log, $match, PREG_SET_ORDER); */

/* //echo "$ptn <br />"; */

/* if ($match_count) { */
/*   echo "{$match_count} actions <br />"; */

/*   foreach ($match as $matched) { */
/*     echo(sprintf("<pre>%s</pre>", $matched[0])); */
/*     echo "<br /><hr /><br />"; */
/*   } */

/* } */
?>